<style>
	.amap-wrapper {
		width: 900px;
		height: 600px;
	}
	
	.amap-demo {
		height: 100px;
	}
</style>
<template>
	<div>
		<Modal v-model="modalShow" :closable='false' :mask-closable=false fullscreen>
			<p slot="header">违章详情</p>
			<Row>
				<Col span="16">
				<Form ref="formData" :model="formData" label-position="left" :label-width="100">
				

					<FormItem label="姓名" prop="realname">
						<Input v-model="formData.realname" readonly=""/>
					</FormItem>

					<FormItem label="联系电话" prop="username">
						<Input v-model="formData.username" readonly=""/>
					</FormItem>
					
					<FormItem label="车牌号" prop="break_car_sn">
						<Input v-model="formData.break_car_sn" readonly=""/>
					</FormItem>
					
					<FormItem label="订单号" prop="order_sn">
						<Input v-model="formData.order_sn" readonly=""/>
					</FormItem>
					

					<FormItem label="违法行为" prop="break_action">
						<Input v-model="formData.break_action" readonly=""/>
					</FormItem>

					<FormItem label="时间" prop="break_time">
						<Input v-model="formData.break_time" readonly=""/>
					</FormItem>
					
					<FormItem label="地点" prop="break_address">
						<Input v-model="formData.break_address" readonly=""/>
					</FormItem>
					
					<FormItem label="罚款" prop="break_price">
						<Input v-model="formData.break_price" readonly=""/>
					</FormItem>
					
					<FormItem label="扣分" prop="break_score">
						<Input v-model="formData.break_score" readonly=""/>
					</FormItem>
					
					<FormItem label="处理方式" prop="handle_type_text">
						<Input v-model="formData.handle_type_text" readonly=""/>
					</FormItem>
					
					<FormItem label="自行处理天数" prop="handle_day">
						<Input v-model="formData.handle_day" readonly=""/>
					</FormItem>
					
					<FormItem label="违章内容" prop="break_intro">
						<Input type="textarea" :rows="4" v-model="formData.break_intro" readonly=""/>
					</FormItem>

				</Form>
				</Col>
			</Row>

			<div slot="footer">
				<Button type="text" @click="cancel">取消</Button>
				<Button v-if="formData.status == -1" type="primary" @click="edit" :loading='saveLoading'>确认已处理 </Button>
			</div>
		</Modal>

	</div>
</template>
<script>
	import {
		getInfo,
		changeStatus,
	} from '@/api/break'

	//import Editor from '_c/editor'
	//import Upload from '_c/common/upload'
	export default {
		components: {
			//  Editor,
			//  Upload
		},
		props: {
			modalId: {
				type: Number,
				default: 0
			}
		},
		created() {
			let t = this;
			if(this.modalId > 0) {
				this.getInfoById()
			}
			//t.getSearchDataExcute();
		},
		data() {
			let t = this;
			return {
				modalShow: true,
				saveLoading: false,
				mapModal: false,
				mapModal1: false,
//				getSearchData: {
//					dot: [],
//				},
				formData: {
					break_id:'',
					username: '',
					realname: '',
					break_car_sn:'',
					order_sn: '',
					break_action: '',
					break_time: '',
					break_address: '',
					break_price:'',
					break_score:'',
					handle_type_text:'',
					handle_day:'',
					break_intro:'',
					status:''
				}
			}
		},
		methods: {
			getInfoById() {
				let t = this
				getInfo(t.modalId).then(res => {
					console.log(res);
					if(res.data.code == 1){
						let res_data = res.data.data;
					    t.formData =  {
								break_id:res_data.break_id,
								username:res_data.username,
								realname: res_data.realname,
								break_car_sn:res_data.break_car_sn,
								order_sn: res_data.order_sn,
								break_action: res_data.break_action,
								break_time: res_data.break_time,
								break_address: res_data.break_address,
								break_price:res_data.break_price,
								break_score:res_data.break_score,
								handle_type_text:res_data.handle_type_text,
								handle_day:res_data.handle_day,
								break_intro:res_data.break_intro,
								status:res_data.status
						}
					    
					
					}else{
						t.$Notice.error({
							title: res.data.msg
						})
						this.$emit('on-edit-modal-hide')
						this.modalShow = false
					}
					
				})

			},
//			getSearchDataExcute() {
//				let t = this;
//				getData().then(res => {
//					t.getSearchData.dot = res.data.data.dot;
//				}, function(error) {})
//			},
			edit() {
				let t = this
				t.$refs.formData.validate((valid) => {
					if(valid) {
						t.saveLoading = true
						console.log(JSON.stringify(t.formData));
						changeStatus(t.formData.break_id).then(res => {
							if(res.data.code == 1) {
								t.saveLoading = false
								t.modalShow = false
								t.$emit('on-edit-modal-success')
								t.$emit('on-edit-modal-hide')
								t.$Notice.success({
									title: res.data.msg
								})
							} else {
								t.saveLoading = false
								t.$Notice.error({
									title: res.data.msg
								})
							}

						}, function(error) {
							t.saveLoading = false
						})
					}
				})
			},
			cancel() {
				this.$emit('on-edit-modal-hide')
				this.modalShow = false
			}
		},

	}
</script>